import request from '@/utils/request';

export interface Company {
  id: string;
  tenantId: string;
  name: string;
  code?: string;
  description?: string;
  status: 'active' | 'inactive';
  createdAt: string;
  updatedAt: string;
}

export interface GetCompaniesParams {
  page?: number;
  pageSize?: number;
  name?: string;
  code?: string;
  status?: string;
}

/**
 * 获取公司列表
 */
export const getCompanies = (params?: GetCompaniesParams) => {
  return request.get('/companies', { params });
};

/**
 * 获取公司详情
 */
export const getCompanyById = (id: string) => {
  return request.get(`/companies/${id}`);
};

/**
 * 创建公司
 */
export const createCompany = (data: Partial<Company>) => {
  return request.post('/companies', data);
};

/**
 * 更新公司
 */
export const updateCompany = (id: string, data: Partial<Company>) => {
  return request.put(`/companies/${id}`, data);
};

/**
 * 删除公司
 */
export const deleteCompany = (id: string) => {
  return request.delete(`/companies/${id}`);
};

